package cn.tedu.elo.petForum.controller;

import cn.tedu.elo.base.response.JsonResult;
import cn.tedu.elo.petForum.pojo.dto.PostParam;
import cn.tedu.elo.petForum.pojo.dto.PostQuery;
import cn.tedu.elo.petForum.pojo.vo.PostVo;
import cn.tedu.elo.petForum.service.ForumService;
import cn.tedu.elo.user.pojo.dto.UserQuery;
import cn.tedu.elo.user.pojo.dto.UserSaveParam;
import cn.tedu.elo.user.pojo.vo.UserVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/post")
public class ForumController {
    @Autowired
    ForumService forumService;
    @PostMapping("save")
    public JsonResult savePost(PostParam postParam){
        log.debug("保存帖子:postParam={}", postParam);
        forumService.savePost(postParam);
        return JsonResult.ok();
    }
    @GetMapping("select")
    public JsonResult selectPost(PostQuery postQuery){
        log.debug("查询帖子:postQuery={}", postQuery);
        List<PostVo> list = forumService.selectPost(postQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("delete/{id}")
    public JsonResult deletePost(@PathVariable Long id){
        log.debug("删除帖子:id={}", id);
        forumService.deletePost(id);
        return JsonResult.ok();
    }
}
